package com.njlime.cms.service.app;

import com.njlime.cms.entities.CommunityUp;
import com.njlime.cms.repository.app.AppCommunityUpDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by Dean on 2017/10/10.
 */
@Service
public class AppCommunityUpService {
    @Resource
    AppCommunityUpDao appCommunityUpDao;

    /**
     * 评论数量
     * @param community_id
     * @return
     */
    public Integer upCount(Integer community_id){
        return appCommunityUpDao.upCount(community_id,null);
    }

    /**
     * 点赞
     */
    @Transactional(readOnly = false)
    public void save(CommunityUp communityUp) {
        appCommunityUpDao.save(communityUp);
    }
    /**
     * 判断当前information评论是否被点赞
     */
    public Boolean isUped(Integer commentId, Integer userId) {
        int upCount = appCommunityUpDao.upCount(commentId, userId);
        if(upCount>0){
            return true;
        }else{
            return false;
        }
    }
}
